using System;
using System.Collections.Generic;
using System.Text;

using System.Net;
using System.Net.Sockets;

namespace Parsifal
{


    public class ClientPlus
    {
        private Socket mSock;
        private string mNickName;
        private bool mBroadcastServer = false;
        private string mIDClient = "";
        private string mExternIPAddress;
        private int mPortConnection;
        private int mIndex;
        private eProtocolServerEvent mState;

        public ClientPlus(Socket client)
        {
            //costruttore

            mSock = client;

            //mExternIPAddress = GetExternIPAddress();
            
            CreateIDClient();
        }



        public bool isBroadcastServer
        {
            get
            {
                return mBroadcastServer;
            }
            set
            {
                mBroadcastServer = value;
            }
        }

        public string NickName
        {
            get
            {
                return mNickName;
            }
            set
            {
                mNickName = value;
            }
        }

        public int PortConnection
        {
            get
            {
                return mPortConnection;
            }
            set
            {
                mPortConnection = value;
            }
        }

        public string ExternIPAddress
        {
            get
            {
                return mExternIPAddress;
            }
            set
            {

                mExternIPAddress = value;
            }
        }

        public int Index
        {
            get
            {
                return mIndex;
            }
            set
            {
                mIndex = value;
            }
        }

        public Socket Socket
        {
            get
            {
                return mSock;
            }

        }

        public eProtocolServerEvent State
        {
            get
            {
                return mState;
            }
            set
            {
                mState = value;
            }
        }

        public eProtocolServerEvent eProtocolServerEvent
        {
            get
            {
                throw new System.NotImplementedException();
            }
            set
            {
            }
        }






        public void CreateIDClient()
        {
            //random number

        }

        /// <summary>
        /// chiamata ad un webservice che mi da l'ip esterno del client
        /// </summary>
        public string GetExternIPAddress()
        {
            try
            {
                string p2 = "";
                //lavori futuri
                //TODO : TOGLIERE COMMENTO
                daxWS.Service1 p1 = new daxWS.Service1();
                p2 = p1.getIP();

                return p2;
            }
            catch (Exception err)
            {
                Exception errDax = new Exception("Problemi con la ricezione dell'indirizzo esterno! Il programma potrebbe non funzionare correttamente!");
               

                throw errDax; ;
            }
        }
    }
}
